﻿using AutoMapper;
using Comm100.Application.Services;
using Comm100.Framework.Auditing;
using Comm100.Framework.Authorization;
using Comm100.Public.Audit;
using Bot.Application.Dto;
using Bot.Application.Services;
using Bot.Domain.Bo;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using Bot.Domain;

namespace Bot.Application.AgentAssists.Service
{
    public class AgentAssistAppService : BaseAppService, IAgentAssistAppService
    {
        private IAgentAssistDomainService _domainService;

        public AgentAssistAppService(IAgentAssistDomainService domainService) : base()
        {
            this._domainService = domainService;
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        [Audit(BotEntity.AGENTASSIST, AuditAction.DESTROY)]
        public void Delete(Guid id)
        {
            _domainService.Delete(id);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        [Audit(BotEntity.AGENTASSIST, AuditAction.CREATE)]
        public AgentAssistDto Add(AgentAssistCreateDto dto)
        {
            var obj = Mapper.Map<AgentAssist>(dto);
            obj.Id = Guid.NewGuid();
            //obj.SiteId = siteId;
            AgentAssist agentAssist = _domainService.Create(obj);
            return Mapper.Map<AgentAssistDto>(agentAssist);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        [Audit(BotEntity.AGENTASSIST, AuditAction.UPDATE)]
        public AgentAssistDto Update(AgentAssistUpdateDto dto)
        {
            var obj = Mapper.Map<AgentAssistUpdateBo>(dto);
            //obj.SiteId = siteId;
            AgentAssist agentAssist = _domainService.Update(obj);
            return Mapper.Map<AgentAssistDto>(agentAssist);
        }

        public AgentAssistDto Get(Guid id)
        {
            AgentAssist agentAssist = _domainService.Get(id);
            return Mapper.Map<AgentAssistDto>(agentAssist);
        }

        public AgentAssistDto Get()
        {
            AgentAssist agentAssist = _domainService.GetBySiteId();
            return Mapper.Map<AgentAssistDto>(agentAssist);
        }

    }
}
